package com.liao.badminton.code.util;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.liao.badminton.code.ProjectException;

import java.util.List;

public class CheckUtil {

    public static void checkValue(String param, String message) {
        if (StrUtil.isBlank(param)) {
            ProjectException.newException(message);
        }
    }
    public static void checkValue(String param, String value, String message) {
        if (StrUtil.isBlank(param) ||!param.equals(value)) {
            ProjectException.newException(message);
        }
    }

    public static void checkValue(Long param, String message) throws ProjectException {
        if (param == null) {
            ProjectException.newException(message);
        }
    }
    public static void checkValue(Long param,Long value, String message) throws ProjectException {
        if (param == null ||!param.equals(value)) {
            ProjectException.newException(message);
        }
    }

    public static void checkValue(Integer param, String message) throws ProjectException {
        if (param == null) {
            ProjectException.newException(message);
        }
    }
    public static void checkValue(Integer param, Integer value, String message) throws ProjectException {
        if (param == null ||!param.equals(value)) {
            ProjectException.newException(message);
        }
    }
    public static void checkValue(Integer param, List<Integer> value, String message) throws ProjectException {
        if (param == null ||!value.contains(param)) {
            ProjectException.newException(message);
        }
    }

    public static void checkValue(List param, String message) throws ProjectException {
        if (CollUtil.isEmpty(param)) {
            ProjectException.newException(message);
        }
    }

    public static void checkValue(Object param, String message) {
        if (param == null) {
            ProjectException.newException(message);
        }
    }

    public static void checkDbNotData(Object dbDate, String message) throws ProjectException {
        if (dbDate == null) {
            ProjectException.newDataNullException(message);
        }
    }

    public static void checkDbAlreadyData(Object dbDate, String message) throws ProjectException {
        if (dbDate != null) {
            ProjectException.newDataAlreadyException(message);
        }
    }
}
